package com.xiyu.service.controller.admin.office;
import com.xiyu.service.vo.office.building.BuildingSimpleUnitGetOutput;
import com.xiyu.service.vo.office.building.BuildingSimpleFloorGetOutput;
import com.xiyu.service.vo.office.building.BuildingSingleGetOutput;
import com.xiyu.service.vo.office.building.BuildingUpdateInput;
import com.xiyu.service.vo.office.building.BuildingCreateInput;
import com.xiyu.service.vo.office.building.BuildingPageQueryOutput;
import com.xiyu.service.vo.office.building.BuildingPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.office.BuildingService;

@Tag(name = "办公楼管理")
@RestController
@RequestMapping("/office/building")
@Validated
public class BuildingController {

    @Resource
    private BuildingService buildingService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询办公楼")
    @PreAuthorize("@ss.hasPermission('office:building:query')")
    public CommonResult<PageResult<BuildingPageQueryOutput>> pageQuery(@Valid BuildingPageQueryInput inputVO) {
        return success(buildingService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增办公楼")
    @PreAuthorize("@ss.hasPermission('office:building:create')")
    public CommonResult<Long> create(@Valid @RequestBody BuildingCreateInput inputVO) {
        return success(buildingService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新办公楼")
    @PreAuthorize("@ss.hasPermission('office:building:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody BuildingUpdateInput inputVO) {
        return success(buildingService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个办公楼")
    @Parameter(name = "id", description = "办公楼主键ID", example = "")
    public CommonResult<BuildingSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(buildingService.singleGet(id));
    }

    @GetMapping("/simple-floor-get")
    @Operation(summary = "根据buildingId获取办公楼层")
    @Parameter(name = "id", description = "办公楼主键ID", example = "")
    public CommonResult<List<BuildingSimpleFloorGetOutput>> simpleFloorGet(@RequestParam("id") Long id) {
        return success(buildingService.simpleFloorGet(id));
    }

    @GetMapping("/simple-unit-get")
    @Operation(summary = "根据buildingId获取办公楼单元")
    @Parameter(name = "id", description = "办公楼主键ID", example = "")
    public CommonResult<List<BuildingSimpleUnitGetOutput>> simpleUnitGet(@RequestParam("id") Long id) {
        return success(buildingService.simpleUnitGet(id));
    }

}
